package son.nt.util;

import android.content.Context;
import android.util.Log;

import com.google.android.apps.analytics.GoogleAnalyticsTracker;

public class GoogleAnaTool {
	private static final String TAG = "GoogleAnaTool";
	private static GoogleAnalyticsTracker tracker = null;
	private static String mGA = "UA-33960822-1";
	public synchronized static void start(Context mContext){
		if(tracker!= null){
			stop();
		}
		tracker = GoogleAnalyticsTracker.getInstance();
		tracker.startNewSession(mGA, 0, mContext);
	}
	public synchronized static void stop(){
		if(tracker != null){
			GoogleAnalyticsTracker.getInstance().stopSession();
			tracker = null;
		}
	}
	public synchronized static void track(String page){
		if(tracker != null){
			tracker.trackPageView(page);
			tracker.dispatch();
			Log.v(TAG, "track page:" + page);
		}
	}
	public synchronized static void trackEvent(String IdTrack){
		if(tracker != null){
			tracker.trackEvent(IdTrack, null, null, 0);
		}
	}
}
